import bindBoxCard from "./bindBoxCard/index";
import unpackingGoods from "./unpackingGoods/index";
export default {
  data() {
    return {
      active: '',
      explainShow: false,
      unpackingShow: false,
      levelData: [],
      activeData: [],
      searchVal: ""
    };
  },
  mounted() {
    this.getLevelData();
  },
  methods: {
    async getLevelData() {
      let url = this.$route.params.id ? "plugin.new-blind-box.frontend.activity.activity-level" : "plugin.new-blind-box.frontend.activity.level";
      let form =  this.$route.params.id ? { id: this.$route.params.id } : ""
      let data = await $http.get(url, {...form});
      if (data.result) {
        this.levelData = data.data.list;
        this.active = data.data.list[0].id;
        this.searchActivityGoods();
      } else {
        this.$toast(data.msg);
      }
    },
    async searchActivityGoods() {
      let url = this.$route.params.id ? "plugin.new-blind-box.frontend.activity.search-activity-goods" : "plugin.new-blind-box.frontend.activity.search-level-goods";
      let form =  this.$route.params.id ? {id:this.$route.params.id ,level_id : this.active, search : {
            goods_keyword : this.searchVal
          }} : 
          {level_id : this.active, search : {
            goods_keyword : this.searchVal
          }}
      let data = await $http.post(url, {...form});
      console.log(data,11111);
      if (data.result) {
        this.activeData = data.data.goods ? data.data.goods : data.data.list
      } else {
        this.$toast(data.msg);
      }
    },
  },
  components: { bindBoxCard , unpackingGoods },
};
